<template>
  <!-- 货运单明细-->
  <div>
    <FormPanel ref="from" :list="formList" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <FilterTable
      ref="table"
      :columns="columns"
      :dataSource="tableList"
      :isMemoryPagination = "true"
      columnsRef="shipmentOrderDetail"
      :isSelectColumn="false"
      height='auto'
      :onColumnsChange="(columns) => (this.columns = columns)"
    >
    </FilterTable>
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer()">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { queryShipmentOrderById } from '@/api/omSale/OrderManagement/ShipmentOrderQuery';
import { dictionary } from '@/utils/dictMixin';
import moment from 'moment';
export default {
  name: 'shipmentOrderDetail',
  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom(),
      columns: this.createdTable(),
      tableList: []
    };
  },
  components: {},
  props: ['rowData'],
  created() {
    this.init(this.rowData);
  },
  mixins: [dictionary],
  methods: {
    async init(data) {
      console.log('传入参数',data);
      for (let i in data) {
          this.formList.map((x) => {
            if (x.fieldName == i) {
              x.initialValue = data[i];
            }
          });
        }
      let res = await queryShipmentOrderById({shipmentOrderId: data.shipmentOrderId});
      if (res.resultCode == 200) {
        this.tableList = res.data.orderList;
      } 
    },
    closeDrawer() {
      this.$emit('close');
    },  
    createdFrom() {
        return [
          {
            type: 'BREAK_SPACE',
            label: '货运信息',
          },
          {
            type: 'INPUT',
            label: '货运单号',
            fieldName: 'shipmentOrderNo',
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '经销商名称',
            fieldName: 'dealerName',
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '收车地址',
            fieldName: 'address',
            disabled: true
          },
          {
            type: 'INPUT',
            label: '送达城市',
            fieldName: 'deliveryCityName',
            disabled: true,        
          },
          {
            type: 'INPUT',
            label: '联系人',
            fieldName: 'linkMan',
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '发车基地',
            fieldName: 'carrierBase',
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '物流公司',
            fieldName: 'carrierCompany',
            disabled: true,
          },
          {
            type: 'DATE',
            label: '发车时间',
            fieldName: 'carrierDate',
            placeholder: '请输入',
            dateFormat: 'yyyy-MM-dd HH:mm:ss',
            dateType: 'datetime',
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '车牌号',
            fieldName: 'trailerBrand',
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '驾驶员姓名',
            fieldName: 'carrierDriver',
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '驾驶员电话',
            fieldName: 'carrierDriverPhone',
            disabled: true,
          }, 
          {
            type: 'INPUT',
            label: '驾驶员身份证',
            fieldName: 'carrierDriverIdCard',
            disabled: true,
          }, 
          {
            type: 'INPUT',
            label: '板次',
            fieldName: 'frequency',
            disabled: true,
          },
          {
            type: 'BREAK_SPACE',
            label: '车辆信息'
          }
        ];
    },  
    createdTable() {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 80,
            sorter: true,
            fixed: 'left',
            render: (props) => {
              return <span>{props.row.index + 1}</span>;
            },
          },
          {
            title: '车型',
            dataIndex: 'modelName',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: 'VIN',
            dataIndex: 'vin',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '外饰',
            dataIndex: 'colorName',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '电机号',
            dataIndex: 'motorNo',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '电池号',
            dataIndex: 'batteryNo',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '电池厂家',
            dataIndex: 'batteryOem',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: 'SAP销售单号',
            dataIndex: 'sapNo',
            sorter: true,
            filter: true,
            filterType: 'input',
          }
        ];
      }
  },
};
</script>
